import java.io.IOException;
import java.net.ServerSocket;
import java.util.ArrayList;
import java.util.Scanner;

public class CoffeePotServer {

	/**
	 * @param args
	 */

	public static void main(String[] args) {
		ServerSocket server;
		Scanner scan = new Scanner(System.in);
		boolean debug = false;
		Protocall newClient;
		ArrayList<CoffeePot> pots = new ArrayList<CoffeePot>();
		
		System.out.print("Debug mode Y/n?\n");
		if (scan.next().equalsIgnoreCase("Y")) {
			debug = true;
		}
		//Hard coded coffee pots
		CoffeePot pot0 = new CoffeePot(35, 20, debug, 0);
		pot0.start();
		CoffeePot pot1 = new CoffeePot(35, 20, debug, 1);
		pot1.start();
		CoffeePot pot2 = new CoffeePot(35, 20, debug, 2);
		pot2.start();
		pot0.addAddition("Cream", 20);
		pot0.addAddition("Half and half", 15);
		pot0.addAddition("Whiskey", 100);
		pot0.addAddition("Vanilla", 50);
		pot1.addAddition("Cream", 20);
		pot1.addAddition("Half and Half", 15);
		pot1.addAddition("Whiskey", 100);
		pot1.addAddition("Vanilla", 50);
		pot2.addAddition("Cream", 20);
		pot2.addAddition("Half and Half", 15);
		pot2.addAddition("Whiskey", 100);
		pot2.addAddition("Vanilla", 50);
		pots.add(pot0);
		pots.add(pot1);
		pots.add(pot2);

		try {
			server = new ServerSocket(3434);
			while (true) {
				newClient = new Protocall(server.accept(), pots, debug);
				newClient.start();
			}
		} catch (IOException e) {
			e.printStackTrace();
		}

	}
}
